package com.demo.chattest.chat;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.MultipleItemRvAdapter;
import com.demo.chattest.bean.MessageInfo;

import java.util.List;

/**
 * @Package com.demo.chattest.chat
 * @Describe 聊天适配器
 * @Author wugx
 * @Date 2020-09-25
 */
public class ChatAdapter extends MultipleItemRvAdapter<MessageInfo, BaseViewHolder> {


    public ChatAdapter(@Nullable List<MessageInfo> data) {
        super(data);
        finishInitialize();
    }

    @Override
    protected int getViewType(MessageInfo messageInfo) {
        //消息-类型 1：发送普通消息 2：接收普通消息  3：发送图片  4：接收图片  5：发送音频 6：接收音频  7：发送视频  8：接收视频
        return messageInfo.getType();
    }

    @Override
    public void registerItemProvider() {
        mProviderDelegate.registerProvider(new SendTextItemProvider());
        mProviderDelegate.registerProvider(new ReceiverTextItemProvider());
        mProviderDelegate.registerProvider(new SendImageItemProvider());
        mProviderDelegate.registerProvider(new ReceiverImageItemProvider());
        mProviderDelegate.registerProvider(new SendAudioItemProvider());
        mProviderDelegate.registerProvider(new ReceiverAudioItemProvider());
        mProviderDelegate.registerProvider(new SendVideoItemProvider());
        mProviderDelegate.registerProvider(new ReceiverVideoItemProvider());
    }
}
